var app = new Vue({
  el: "#app",
  data: {
    role: "", // 角色
    list: [],
    total: 0,
    pageNumber: 1,
    pageSize: 10,
    loading: false,
  },
  mounted() {
    this.role = window.role;
    this.getInfoList("init");
  },
  methods: {
    // 获取列表
    getInfoList(type) {
      if (type !== "init") {
        this.pageNumber = 1;
      }
      this.loading = true;
      apiGetInfoList({
        pageNumber: this.pageNumber,
        pageSize: this.pageSize,
      })
        .then((res) => {
          const { data, total } = res;
          this.list = data;
          this.total = total;
          this.loading = false;
          this.$refs.table.doLayout();
        })
        .catch((err) => {
          this.list = [];
          this.total = 0;
          this.loading = false;
          this.$message.error(err && err.msg);
        });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageNumber = 1;
      this.getInfoList("init");
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageNumber = val;
      this.getInfoList("init");
    },
  },
});
